#include<iostream>
using namespace std;
#include<vector>
#include<string>
class Solution {
public:
    int numDistinct(string& s, string& t) {
        int ans = 0;
        int n1 = s.size(), n2 = t.size();
        vector<unsigned int> dp(n2 + 1);
        dp[0] = 1;
        for (int i = 1; i <= n1; ++i)
            for (int j = n2; j >= 1; --j)
                if (s[i - 1] == t[j - 1])
                    dp[j] += dp[j - 1];
        return dp.back();
    }
};